"""Flux function for the Isothermal equations"""

import numpy

from flux_functions import LxfFlux

def isothermal_equations_flux(q, a):
    f = numpy.zeros_like(q)

    rho = q[0]
    u = q[1]/rho

    f[0] = rho * u
    f[1] = rho * u * u + a * a * rho

    return f

class IsothermalEquationsLxfFlux(LxfFlux):

    def __init__(self, a=1.0, muscl=0, ppm=-1, eno=-1):
        LxfFlux.__init__(self, muscl, ppm, eno)
        self.a = a

    def _compute_unstable_flux(self, ql, qr):
        return  0.5 * ( isothermal_equations_flux(ql,self.a) + \
                        isothermal_equations_flux(qr,self.a) )

    def _compute_max_sound_speed(self):
        return self.a
